<template>
  <div class="login-container">
    <!-- 顶部栏 -->
    <van-nav-bar
      title="登录页"
      left-text="返回"
      left-arrow
      @click="$router.back()"
    />
    <!-- 输入框 -->
    <van-form @submit="onSubmit">
      <van-field
        v-model="mobile"
        name="mobile"
        label="手机号"
        placeholder="请输入手机号"
        required
        :rules="[
          { required: true, message: '请填写手机号' },
          {
            pattern: /\d{11}/,
            message: '手机格式不对',
          },
        ]"
      />
      <van-field
        v-model="code"
        type="text"
        name="code"
        label="验证码"
        placeholder="请输入验证码"
        required
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import { userLogin } from "./ues.js";
export default {
  name: "login",
  data() {
    return {
      mobile: "",
      code: "",
    };
  },
  methods: {
    onSubmit(values) {
      userLogin(values).then((res) => {
        console.log(res);
      });
    },
  },
};
</script>

<style lang="less">
.login-container {
  .van-nav-bar__content {
    background-color: #009afb;
    .van-nav-bar__title {
      color: #fff;
    }
    .van-icon-arrow-left {
      color: #fff;
    }
    .van-nav-bar__text {
      color: #fff;
    }
  }
}
</style>
